<?php
require_once "./db_config.php";
$arr=[];
if(isset($_POST['state'])){
    if($_POST['state']=='1'){
        $id=$_POST['id'];
        $sql="SELECT * FROM handle_history WHERE `id`='$id'";
        $result=mysqli_query($conn,$sql);
        if(mysqli_num_rows($result) > 0){
            while($row = mysqli_fetch_assoc($result)) {
                $arr[]=$row;
            }
            echo json_encode($arr,JSON_UNESCAPED_UNICODE);
         }
    }else{
        $id=$_POST['id'];
        $name=$_POST['name'];
        $handle=$_POST['handle'];
        $time=$_POST['time'];
        $dept=$_POST['dept'];
        if(isset($_POST['tips'])){
            $tips=$_POST['tips'];
        }else{
            $tips='';
        }
        $sql="INSERT INTO handle_history(id,name,handle,time,dept,tips) VALUE('$id','$name','$handle','$time','$dept','$tips')";
        $result=mysqli_query($conn,$sql);
        if(!$result){
           
        }else{
            echo 'success';
        }
    }
}
mysqli_close($conn);
?>